<?php

	$site_root = "";
	require_once ($site_root . "common/PinSQL.obj");
	$pinSQL = new PinSQL();
	
	
	

?>

<div class="head">Most Active Users</div>

<p />Top 10 most active users on the Pin Project:

<p />

<table>

<?php

	$pinSQL->Query("SELECT * FROM activity");
	
	$total = $pinSQL->GetNumRows();
	
	while ( $row = $pinSQL->FetchNextRow() )
	{
		$events[ $row['by_user'] ]++;
	}
	
	arsort( $events );
	
	$i=0;
	
	foreach( $events as $user => $count )
	{
		if ($i < 10)
		{
			
		if (!$i)
		{
			$max = $count;
		}
		
		$i++;
		$width = round(($count / $max) * 450, 1);
		$percent = round( $count*100 / $total, 1 );
		
		if (!$user)
			$user = "(general)";

?>

	<tr>
		<td><span class="redtext"><small><?php echo $i . " "; ?></small></span><?php echo $pinSQL->GetFullName($user); ?>
		<?php if ($i==1) { ?><div class="accent">Most active</div><?php } ?></td>
		<td>
			<img src="/img/bar.png" width="<?php echo $width; ?>" height="16"/><img src="/img/bar_dead.png" width="<?php echo (450 - $width); ?>" height="16"/>
			
			<div class="subtle"><?php echo $percent; ?>% of site activity, with <?php echo $count; ?> events
		</td>
	</tr>

<?php
	}
	}

?>


	
</table>

<div class="horizontal_separation" style="clear: both;"></div>
<div class="horizontal_separation" style="clear: both;"></div>

<img src="/img/copyright_footer_blue.png" />

<div class="horizontal_separation" style="clear: both;"></div>
<div class="horizontal_separation" style="clear: both;"></div>